from collections import defaultdict
# 输入
word = input()

dict_chactor = defaultdict(int)
max_list = list()
for i in word:
    dict_chactor[i]+=1

a = max(dict_chactor.keys(),key=lambda x:dict_chactor[x])
for key ,vale in dict_chactor.items():
    if vale == dict_chactor[a]:
        max_list.append(key)
max_list.sort()

print(max_list[0])
print(dict_chactor[a])